package v1

import (
	"gitee.com/liangziyisheng/caas-platform-mc/internal/model/do"

	"gitee.com/liangziyisheng/caas-platform-mc/internal/model/entity"

	"github.com/gogf/gf/v2/frame/g"
)

type ListReq struct {
	g.Meta     `path:"/users" tags:"用户管理" method:"get" summary:"用户列表"`
	EmployeeNo string `json:"employeeNo" description:"人员编号"`
	Username   string `json:"username" description:"用户名"`
	Fullname   string `json:"fullname" description:"姓名"`
	Phone      string `json:"phone" description:"手机号"`
	Page       int    `json:"page"   v:"required|min:1"     description:"页码"`
	Size       int    `json:"size" v:"required|between:1,100"       description:"每页条数"`
}
type ListRes struct {
	g.Meta `mime:"application/json"`
	Data   []User `json:"data"`
	Total  int    `json:"total"`
}

type User struct {
	Id         int64  `json:"id"             description:""`
	Username   string `json:"username"     description:"用户名"`
	Type       int    `json:"type" description:"用户类型: 登陆用户1和非登陆用户2"`
	Fullname   string `json:"fullname"         description:"姓名"`
	Email      string `json:"email"       description:"邮箱"`
	Phone      string `json:"phone"        description:"电话"`
	Status     bool   `json:"status"         description:"状态: 启用1和禁用0"`
	EmployeeNo string `json:"employeeNo"    description:"人员编号"`
}

type AddReq struct {
	g.Meta     `path:"/users" tags:"用户管理" method:"post" summary:"添加用户"`
	EmployeeNo string `json:"employeeNo"    description:"人员编号"`
	Username   string `json:"username" v:"required#用户名不能为空" description:"用户名"`
	Password   string `json:"password" v:"required#密码不能为空" description:"密码"`
	Type       int    `json:"type" v:"required#类型不能为空" description:"用户类型: 登陆用户1和非登陆用户2"`
	Fullname   string `json:"fullname" v:"required#姓名不能为空" description:"姓名"`
	Email      string `json:"email" description:"邮箱"`
	Phone      string `json:"phone" v:"required#手机号不能为空|phone#手机号格式错误" description:"电话"`
}
type AddRes struct {
	g.Meta `mime:"application/json"`
	Id     int64 `json:"id"`
}

type UpdateReq struct {
	g.Meta     `path:"/users/{id}" tags:"用户管理" method:"put" summary:"更新用户"`
	Id         int    `query:"id" v:"required|min:1"`
	Type       int    `json:"type"`
	Fullname   string `json:"fullname"`
	Email      string `json:"email"`
	Phone      string `json:"phone"`
	Status     bool   `json:"status" v:"required#状态不能为空"`
	EmployeeNo string `json:"employeeNo"    description:"人员编号"`
}
type UpdateRes struct {
	g.Meta `mime:"application/json"`
	Rows   int64 `json:"rows" description:"修改成功的行数"`
}

type DeleteReq struct {
	g.Meta `path:"/users/{id}" tags:"用户管理" method:"delete" summary:"删除用户"`
	Id     int64 `query:"id" v:"required|min:1"`
}
type DeleteRes struct {
	g.Meta `mime:"application/json"`
	Rows   int64 `json:"rows" description:"删除成功的行数"`
}

type InfoReq struct {
	g.Meta `path:"/users/{id}" tags:"用户管理" method:"get" summary:"用户详情"`
	Id     int64 `query:"id" v:"required|min:1"`
}
type InfoRes struct {
	g.Meta `mime:"application/json"`
	Id     int64             `json:"id"`
	Roles  []entity.UserRole `json:"roles"`
}

// input and output struct
type ListInput struct {
	TenantCode string `json:"tenantCode"`
	EmployeeNo string `json:"employeeNo"`
	Fullname   string `json:"fullname"`
	Username   string `json:"username"`
	Phone      string `json:"phone" `
	Page       int    `json:"page" description:"页码"`
	Size       int    `json:"size" description:"每页条数"`
}

type ListOutput struct {
	Data  []entity.User `json:"data"`
	Total int           `json:"total"`
}
type AddInput struct {
	do.User
}
type AddOutput struct {
	Id int64 `json:"id"`
}
type UpdateInput struct {
	do.User
}
type UpdateOutput struct {
	Rows int64 `json:"rows" description:"修改成功的行数"`
}
type DeleteInput struct {
	Id         int64  `json:"id"`
	TenantCode string `json:"tenantCode"`
}
type DeleteOutput struct {
	Rows int64 `json:"rows" description:"删除成功的行数"`
}
type InfoInput struct {
	Id         int64  `json:"id" v:"required#ID不能为空"`
	TenantCode string `json:"tenantCode"`
}
type InfoOutput struct {
	Id    int64             `json:"id"`
	Roles []entity.UserRole `json:"roles"`
	// Permissions []Permission `json:"permissions"`
}

type Role struct {
	Id          int64  `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

type Permission struct {
	Id          int64  `json:"id"`
	AppCode     string `json:"appCode"`
	AppName     string `json:"appName"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

type Menu struct {
	Id          string `json:"id"`
	AppCode     string `json:"appCode"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Type        int    `json:"type"`   // 菜单类型: 应用1菜单2对话框3操作9
	Path        string `json:"path"`   // 路由
	Parent      string `json:"parent"` // 父菜单ID
}
